<template>
<div class="container">
    <el-form ref="form" :model="form" label-width="80px">

    <el-form-item label="文件编号" >
        <el-input v-model="form.file_id" :disabled="true"></el-input>
    </el-form-item>

    <el-form-item label="文件名" >
        <el-input v-model="form.name" :disabled="true"></el-input>
    </el-form-item>

    <el-form-item label="文件分类">
        <el-input v-model="this.category[form.type-1].value" :disabled="true"></el-input>
    </el-form-item>

    <el-form-item label="小组">
        <el-input v-model="form.group_id" :disabled="true"></el-input>
    </el-form-item>

    

    <el-form-item label="评级">
        <el-select v-model="value" placeholder="请选择">
            <el-option
            v-for="item in filteredList"
            :key="item.id"
            :label="item.value"
            :value="item.id">
            </el-option>
        </el-select>
    </el-form-item>

    <el-form-item label="评论">
        <el-input v-model="form.comment" ></el-input>
    </el-form-item>

    <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
    </el-form-item>
    </el-form>
</div>
</template>


<script>
import { beforCorrectFile, correctFile } from '@/api/user'
export default {
    data() {
        return {
        
            form: [],
            category:[],
            rate:[],
            value:'',
            file_id:'',
            startIndex: 1
        }
    },
    computed:{
        filteredList() {
            return this.rate.slice(this.startIndex);
        }
    },
    methods: {
        onSubmit() {
        correctFile({ 'f_id': this.form.file_id, 'rate': this.value, 'comment': this.form.comment,'t_id':this.$store.getters.t_id }).then(response => {
            this.$message({
                message: response.message,
                type: response.data.message
            })
        })
        }
    },
    created: function() {
        this.$store.commit('user/GET_FID')
        beforCorrectFile(this.$store.getters.f_id).then(response=>{
            this.form= response.data.file
            this.category=response.data.category,
            this.rate=response.data.rate
        })
        
        console.log(this.rate)
    }
}

</script>

<style lang="scss" scoped>
.container{
    width: 50%;
    margin: auto;
    margin-top:10px
}
</style>
    